﻿namespace BeatEmUp.World
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Graphics;
    using Microsoft.Xna.Framework.Input;
    using BeatEmUp.Menu;
    using BeatEmUp.Characters.Enemies;
    using BeatEmUp.HUD;
    using BeatEmUp.Items.Weapons;
    using BeatEmUp.Enums;
    using BeatEmUp.World.Drawable;
    using Microsoft.Xna.Framework.Content;

    public class Element
    {
        protected GameManager game;
        protected Drawable.IDrawable drawable;

        public Vector2 AbsolutePosition
        {
            private set;
            get;
        }

        public float Depth
        {
            private set;
            get;
        }

        public Vector2 Size
        {
            get
            {
                return this.drawable.Size;
            }
        }

        public Element(GameManager game, Vector2 absolutePosition, Drawable.IDrawable drawable, float depth)
        {
            this.game = game;
            this.drawable = drawable;
            this.Depth = depth;
            this.AbsolutePosition = absolutePosition;
        }

        public void LoadContent(ContentManager content)
        {
            this.drawable.LoadContent(content);
        }

        public void Update(GameTime gameTime)
        {
            this.drawable.Update(gameTime);
        }

        public void Draw(GameManager gameManager, GameTime gameTime, int worldPosition)
        {
            this.drawable.Draw(gameManager, gameTime, this.GetRelativePosition(worldPosition));
        }

        public Vector2 GetRelativePosition(int worldPosition)
        {
            Vector2 position = new Vector2();

            position.Y = this.AbsolutePosition.Y;
            position.X = this.AbsolutePosition.X - worldPosition;

            return position;
        }
    }
}
